complexity(pri(naught,[]), 0) :- !.
complexity(ctxm(_,_,_,_,_), 1) :- !.
complexity(pri(_,LST),NP1) :- complexity(LST,N), NP1 is N+1.
complexity([],0).
complexity([X|LST],SUM) :- complexity(X,N1), complexity(LST,N2), SUM is N1+N2.
  
nrules(T,N) :-
  findall(X,clause(elneeded(pri(T,X),_,_),_),LSTX1),length(LSTX1,N).
% was: minus two because of the two generic rules for testneeded! now what should it be?

list_sum([], 0).

list_sum([Head | Tail], TotalSum) :-
  list_sum(Tail, Sum1),
  TotalSum is Head + Sum1.